import ajax from '../../utils/request'
Page({
    data: {
        list: {},
        onClickLeft() {
            wx.showToast({
                title: '点击返回',
                icon: 'none'
            });
        },

    },
    onLoad: function (options) {
        this.getList(options.id)
    },
    async getList(id) {
        let res = await ajax('http://43.136.85.99:3008/film/detail?id=' + id)
        res.premiereAt = this.formateDate(res.premiereAt);
        this.setData({
            list: res
        })
    },
    // 格式化时间
    formateDate(time) {
        if (!time) {
            return '';
        }
        let date = new Date(time);
        let Y = date.getFullYear();
        let M = date.getMonth() + 1;
        let D = date.getDate();
        M = M < 10 ? '0' + M : M;
        D = D < 10 ? '0' + D : D;
        return `${Y}-${M}-${D}`
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    }
})